import request from '../utils/request';

const api = {
    // 用户登录
    userLogin(query) {
        return request({
            url: '/user/login',
            method: 'post',
            params: query
        });
    },
    
    // 管理员认证相关操作
    adminLogin(query) {
        return request({
            url: '/admin/auth/login',
            method: 'get',
            params: query
        });
    },
    loginOut(query) {
        return request({
            url: '/admin/auth/loginOut',
            method: 'get',
            params: query
        });
    },
    getUserManage(query) {
        return request({
            url: '/admin/auth/list',
            method: 'get',
            params: query
        });
    },
    regAdministrator(data){
        return request({
            url: '/admin/auth/add',
            method: 'post',
            data: data
        });
    },
    // 闲置物品管理相关操作
    getGoods(query) {
        return request({
            url: '/admin/item/list',
            method: 'get',
            params: query
        });
    },
    updateGoods(query) {
        return request({
            url: '/admin/item/updateStatus',
            method: 'get',
            params: query
        });
    },
    queryIdle(query) {
        return request({
            url: '/admin/item/query',
            method: 'get',
            params: query
        });
    },
    updateIdleStatus(query) {
        return request({
            url: '/admin/item/updateStatus',
            method: 'get',
            params: query
        });
    },
    // 订单管理相关操作
    getOrderList(query) {
        return request({
            url: '/admin/order/list',
            method: 'get',
            params: query
        });
    },
    deleteOrder(query) {
        return request({
            url: '/admin/order/delete',
            method: 'get',
            params: query
        });
    },
    queryOrder(query) {
        return request({
            url: '/admin/order/query',
            method: 'get',
            params: query
        });
    },
    // 用户管理相关操作
    getUserData(query) {
        return request({
            url: '/admin/user/list',
            method: 'get',
            params: query
        });
    },
    updateUserStatus(query){
        return request({
            url: '/admin/user/updateStatus',
            method: 'get',
            params: query
        });
    },
    queryUser(query) {
        return request({
            url: '/admin/user/query',
            method: 'get',
            params: query
        });
    },
    
    // 用户端商品相关操作
    getIdleItemList(query) {
        return request({
            url: '/user/item/list',
            method: 'get',
            params: query
        });
    },
    getIdleItemByLabel(query) {
        return request({
            url: '/user/item/listByLabel',
            method: 'get',
            params: query
        });
    },
    
    // 创建订单
    createOrder(data) {
        return request({
            url: '/user/order/create',
            method: 'post',
            data: data
        });
    },
    
    // 获取我发布的商品
    getMyPublishedItems() {
        return request({
            url: '/user/item/myPublished',
            method: 'get'
        });
    },
    
    // 获取我的订单
    getMyOrders() {
        return request({
            url: '/user/order/myOrders',
            method: 'get'
        });
    },
    
};

export default api;